package com.hnhcyy.goods.mapper;

import java.util.HashMap;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.hnhcyy.goods.pojo.Medicine;

//商品销量第一表
public interface MedicineMapper {
	
	@Insert("insert into medicine(bar_code,generic_name,element,description,specification,indications,dosage,"+
			"adverse_reactions,contraindication,precautions,storage,fpackage,manufacturer,approval_number)"+
			" values (ifnull(#{barCode},''),ifnull(#{genericName},''),ifnull(#{element},''),ifnull(#{description},''),ifnull(#{specification},''),"+
			"ifnull(#{indications},''),ifnull(#{dosage},''),ifnull(#{adverseReactions},''),ifnull(#{contraindication},''),ifnull(#{precautions},''),"+
			"ifnull(#{storage},''),ifnull(#{fpackage},''),ifnull(#{manufacturer},''),ifnull(#{approvalNumber},''))")
	public int insert(Medicine item);
	
	@Delete("delete from medicine where fid=#{fid}")
	public int delete(Integer fid);
	
	@Update({"<script>",
			"update medicine ",
			"<set>",
			"<if test='barCode != null'>bar_code=#{barCode},</if>",
			"<if test='genericName != null'>generic_name=#{genericName},</if>",
			"<if test='element != null'>element=#{element},</if>",
			"<if test='description != null'>description=#{description},</if>",
			"<if test='specification != null'>specification=#{specification},</if>",
			"<if test='indications != null'>indications=#{indications},</if>",
			"<if test='dosage != null'>dosage=#{dosage},</if>",
			"<if test='adverseReactions != null'>adverse_reactions=#{adverseReactions},</if>",
			"<if test='contraindication != null'>contraindication=#{contraindication},</if>",
			"<if test='precautions != null'>precautions=#{precautions},</if>",
			"<if test='storage != null'>storage=#{storage},</if>",
			"<if test='fpackage != null'>fpackage=#{fpackage},</if>",
			"<if test='manufacturer != null'>manufacturer=#{manufacturer},</if>",
			"<if test='approvalNumber != null'>approval_number=#{approvalNumber},</if>",
			"</set>",
			" where fid=#{fid}",
			"</script>"})
	public int update(Medicine item);
	
	@Select("select fid,bar_code,generic_name,element,description,specification,indications,dosage,adverse_reactions,"+
			"contraindication,precautions,storage,fpackage,manufacturer,approval_number "+
			" from medicine where fid=#{fid}")
	public Medicine select(Integer fid);
}
